import java.util.Date;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 *
 * @author Srdjan
 */
public class Test {
    
    
    String[] namesOfBooks = {"Zlocin i kazna", "Alhemicar", "Na Drini cuprija", "Ana Karanjina", "Sidarta"};
        String[] namesOfPeople = {"Petar Peric", "Miso Misic", "Stevo Stevic", "Mico Micic", "Ana Anic"};
        boolean[] vipStatus = {true, true, false, true, false};
        DateFormat fmt = new SimpleDateFormat("dd/MM/yyyy");
        Date[] datesOfBirth;
        String[] genres = {"Philosophical Novel", "Adventure", "Novel", "Realism novel", "Novel"};
        int[] timesOfRent = {38, 62, 16, 34, 40};
        long[] rentNum = {85L, 90L, 92L, 100L, 89L};
        int[] numOfDaysBorrowed = {7, 18, 10, 26, 14};
        int [] numOfDaysAllowed = {14, 14, 21, 21, 14};

    public Test() throws ParseException {
        this.datesOfBirth = new Date[]{fmt.parse("01/29/1985"), fmt.parse("09/17/1992"), fmt.parse("03/16/1995"), fmt.parse("10/10/1979"), fmt.parse("08/09/1989")};
    }
    
    public static double roundDown2(double d) {
        return (long) (d * 1e2) / 1e2;
    }
    
    public void ispis(){
        for (int i=0; i<5; i++){
            
            Book b;
            b = new Book();
            b.setGenre(genres[i]);
            b.setName(namesOfBooks[i]);
            b.setRentedTimes(timesOfRent[i]);
            
            Person p;
            p = new Person();
            p.setDateOfBirth(datesOfBirth[i]);
            p.setName(namesOfPeople[i]);
            p.setVip(vipStatus[i]);
            
            Borrowing bo;
            bo = new Borrowing();
            bo.setBook(namesOfBooks[i]);
            bo.setBorrowedBy(namesOfPeople[i]);
            bo.setLoanNumber(rentNum[i]);
            bo.setNumberOfDaysBorrowed(numOfDaysBorrowed[i]);
            bo.setNumberOfDaysBorrowedAllowed(numOfDaysAllowed[i]);
            
            System.out.println("Book: " + namesOfBooks[i]);
            System.out.println("Genre: " + genres[i]);
            System.out.println("Borrowed " + timesOfRent[i] + " times");
            System.out.println("Rent no. " + rentNum[i]);
            System.out.println("Borrowed by: " + namesOfPeople[i]);
            System.out.println("Date of birth: " + fmt.format(datesOfBirth[i]));
            if (vipStatus[i] == true)
                System.out.println("VIP: Yes");
            else
                System.out.println("VIP: No");
            System.out.println("Away for " + numOfDaysBorrowed[i] + " days");
            System.out.println("Allowed: " + numOfDaysAllowed[i] + " days");
            System.out.println("Ordinary fee: " + roundDown2(Methods.ordinaryFee(numOfDaysBorrowed[i], numOfDaysAllowed[i], vipStatus[i])));
            System.out.println("Penalty: " + roundDown2(Methods.penalty(numOfDaysBorrowed[i], numOfDaysAllowed[i])));
            System.out.println("Total fee: " + roundDown2(Methods.totalFee(Methods.ordinaryFee(numOfDaysBorrowed[i], numOfDaysAllowed[i], vipStatus[i]),Methods.penalty(numOfDaysBorrowed[i], numOfDaysAllowed[i]))));
            System.out.println();
        }
    }
        
}